
import dayjs from "dayjs";

export const timeRanges = {
  最近1分钟: function () {
    var res = [];
    const currTimestamp = Date.now();
    const fromTimestamp = currTimestamp - 1000 * 60 * 1;
    res.push(dayjs(fromTimestamp));
    res.push(dayjs(currTimestamp));
    return res;
  },
  最近5分钟: function () {
    var res = [];
    const currTimestamp = Date.now();
    const fromTimestamp = currTimestamp - 1000 * 60 * 5;
    res.push(dayjs(fromTimestamp));
    res.push(dayjs(currTimestamp));
    return res;
  },
  最近15分钟: function () {
    var res = [];
    const currTimestamp = Date.now();
    const fromTimestamp = currTimestamp - 1000 * 60 * 15;
    res.push(dayjs(fromTimestamp));
    res.push(dayjs(currTimestamp));
    return res;
  },
  最近30分钟: function () {
    var res = [];
    const currTimestamp = Date.now();
    const fromTimestamp = currTimestamp - 1000 * 60 * 30;
    res.push(dayjs(fromTimestamp));
    res.push(dayjs(currTimestamp));
    return res;
  },
  最近1小时: function () {
    var res = [];
    const currTimestamp = Date.now();
    const fromTimestamp = currTimestamp - 1000 * 60 * 60;
    res.push(dayjs(fromTimestamp));
    res.push(dayjs(currTimestamp));
    return res;
  },
  最近3小时: function () {
    var res = [];
    const currTimestamp = Date.now();
    const fromTimestamp = currTimestamp - 1000 * 60 * 60 * 3;
    res.push(dayjs(fromTimestamp));
    res.push(dayjs(currTimestamp));
    return res;
  }
};
